﻿using System;
using System.Web.UI.WebControls;
using Ue.Infrastructure.DomainBase;
using Ue.Infrastructure.RepositoryFramework;
using Ue.Infrastructure.Web.UI;
using Ue.Qcdz.Domain.SaleCategorys;
using Ue.Framework.Web;
using Ue.Qcdz.Domain.Shops;
using Ue.Qcdz.Domain;
namespace Ue.Qcdz.UI.Controls
{
    public class SaleCategoryGridView : SkinnedGridView, ISaleCategoryDataQuery, Ue.Infrastructure.DomainBase.ISort
    {

        private ISaleCategoryRepository repository;

        public SaleCategoryGridView()
        {
            this.repository = RepositoryFactory.GetRepository<ISaleCategoryRepository, SaleCategory>();
        }

        protected override void GridViewDataBind(object sender, EventArgs args)
        {
            IDataResult<SaleCategory> dataResult = this.repository.FindBy(this);
            Repeater repeater = sender as Repeater;
            repeater.DataSource = dataResult.DataObjects;
            repeater.DataBind();
            this.RecordCount = dataResult.RecordCount;
        }

        protected override string GetSkinFileName()
        {
            return "~/Themes/zh-cn/Skins/SaleCategorys/SaleCategorys.ascx";
        }

        #region ISort 成员

        public string BuildSortStatement()
        {
            return "DisplayOrder DESC";
        }

        #endregion

        #region ISaleCategoryDataQuery 成员

        public bool Status
        {
            get;

            set;

        }


        #endregion

        #region ISaleCategoryDataQuery 成员

        private string shopId = string.Empty;
        public string ShopId
        {
            get
            {
                Shop shop = Domain.SiteContext.GetSiteContext().Shop;
                if (shop != null) return shop.Key.ToString();
                return this.shopId;
            }
            set
            {
                this.shopId = value;
            }
        }

        #endregion

    }
}
